package com.nbst.db.datasource;

import javax.transaction.UserTransaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.transaction.jta.JtaTransactionManager;

import com.atomikos.icatch.jta.UserTransactionImp;
import com.atomikos.icatch.jta.UserTransactionManager;
import com.nbst.comnutil.LogOut;

/**
 * 
 * @ClassName: JtaManagerConfig
 * @Description:全局事务配置
 * @author King
 * @date 2020年6月4日
 *
 */
// @Configuration
public class JtaManagerConfig {
	@Autowired
	LogOut logout;

	@Bean(name = "transactionManager")
	@Primary
	public JtaTransactionManager regTransactionManager() {
		logout.info("正在创建分布式事务...");
		UserTransactionManager userTransactionManager = new UserTransactionManager();
		UserTransaction userTransaction = new UserTransactionImp();
		return new JtaTransactionManager(userTransaction, userTransactionManager);
	}
}
